package com.tensquare.qa.dao;

import com.tensquare.qa.pojo.Problem;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author zzb
 * @create 2020/12/16
 */
public interface ProblemDao extends JpaRepository<Problem,String> {

    //最新问题列表
    @Query(nativeQuery = true,
            value = "select p.* from tb_pl pl,tb_problem p where p.id = pl.problemid and p.id=?1 order by createtime desc ")
    List<Problem> findnewList(Integer labelId, Pageable pageable);

    //查询热门问题列表
    @Query(nativeQuery = true,
    value = "select p.* from tb_problem p,tb_pl pl where p.id = problemid and p.id = ?1 order by reply desc ")
    List<Problem> findhotList(Integer labelId,Pageable pageable);
}
